from CONN import conn
# 获取游标对象
cursor = conn.cursor()
# 捕获操作数据库的异常
try:
    # 执行sql语句
    cursor.execute("select * from student where age>21")
    # 获取查询到的数据
    resultList = cursor.fetchall()
    print("查询到的数据：", resultList)
except Exception as e:
    print("更新数据失败:", e)
finally:
    # 关闭游标和连接是个好习惯
    cursor.close()
    conn.close()